<?php
#基础函数
include_once('_path.php');
include_once("../includes/init.php");
#样式
$css = array();
$js = array();
#菜单
$menu = "card";

#页码
$page = trim($_GET['page']) + 0;
#每页数量
$pagesize = 50;
#获得总页数
$sql = "SELECT count(*) total FROM cards";
$rs = $database->queryArray($sql);
$total_cards= $rs[0]["total"];
$total_page = ceil($total_cards/ $pagesize);
#计算页数
if ($total_page < 1) $total_page = 1;
if ($page < 1) $page = 1;
if ($page > $total_page) $page = $total_page;
#正式读内容
$sql = "SELECT * FROM cards ".
	" LIMIT ".(($page - 1) * $pagesize).", $pagesize";
$rsc = $database->queryArray($sql);

include_once("../layout/_header.php");
?>
    <div class="main">
            <div class="traininc-nav-list">
                            <ul>
                                    <li class="selected"><a href="javascript:;">会员卡列表</a></li>
                                    <li><a href="edit.php?action=add.form">新增会员卡</a></li>

                            </ul>
                    </div>
                    <div class="box-con">
                    			<table class="table-blue">
				<thead>
					<tr>
						<th>编号</th>
						<th>等级</th>
						<th>价格</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
                                <?
                                for($i=0;$i<sizeof($rsc);$i++){
                                $r = $rsc[$i];
                                $j = 1;
                                ?>
                                    <tr <?=iif($j%2==0, 'class="odd"')?>>
						<td><?=$r['id']?></td>
						<td><?=$r['name']?></td>
						<td><?=$r['price']?></td>
						<td><a href="edit.php?action=view.form&id=<?= $r['id'] ?>">查看详细</a> | <a href="edit.php?action=delete.do&id=<?= $r['id'] ?>">删除</a></td>
				    </tr>
                                <?
                                $j++;
                                }
                                ?>
				</tbody>
			</table>
                    </div>
    </div>
<?
include_once("../layout/_footer.php");
?>